<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>教务系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all">

    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<div class="demoTable" style="text-align:center">
    班次名称：
    <div class="layui-inline">
        <input class="layui-input" id="classTemes" autocomplete="off">
    </div>
    讲师姓名：
    <div class="layui-inline">
        <input class="layui-input" id="teacher_name" autocomplete="off">
    </div>
    课程阶段：
    <div class="layui-inline">
        <input class="layui-input" id="stage" autocomplete="off">
    </div>

    <button class="layui-btn" data-type="reload">搜索</button>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-normal" lay-event="student_msg">学生的管理</a>

</script>
<script src="../js/layui/layui.js" charset="utf-8"></script>
<script src="/js/layui/jquery.1.12.4.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#test'
            , url: '/admin/banci/show'
            , data: {classTimes_name:'18'}
             , toolbar: '#toolbarDemo'
            , title: '教师信息表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
                , {field: 'classname', title: '班次名称', width: 120}
                , {field: 'teachername', title: '讲师姓名', width: 120}
                , {field: 'banzhangname', title: '班长', width: 120}
                , {field: 'stage', title: '课程阶段', width: 120}
                , {field: 'banzhuren', title: '班主任', width: 120}
                , {field: 'room', title: '教室信息', width: 150}
                , {field: 'startDate', title: '开课时间', width: 120}
                , {field: 'endDate', title: '结课时间', width: 120}
                , {fixed: 'right', title: '查看', toolbar: '#barDemo', width: 150}
            ]]
            , page: true
            , id: 'testReload'
        });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        classTimes: '' ? '' : $('#classTemes').val(),
                        teacher_Name: '' ? '' : $('#teacher_name').val(),
                        stage: '' ? '' : $('#stage').val()
                    }
                }, 'data');

            }
        };

        $('.demoTable .layui-btn').on('click', function () {

                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';


        })
        ;

        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if(obj.event=="add"){
                layer.open({
                    type: 2,
                    title: "添加",
                    closeBtn: false,
                    shift: 2,
                    area: ['500px', '500px'],
                    shadeClose: true,
                    anim: 3,
                    content: $("#add-tou"),//这里content是一个普通的String

                });
            }
            // switch (obj.event) {
            //     case 'getCheckData':
            //         var data = checkStatus.data;
            //         layer.alert(JSON.stringify(data));
            //         break;
            //     case 'getCheckLength':
            //         var data = checkStatus.data;
            //         layer.msg('选中了：' + data.length + ' 个');
            //         break;
            //     case 'isAll':
            //         layer.msg(checkStatus.isAll ? '全选' : '未全选');
            //         break;
            //
            // }
            ;
        });

        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            //console.log(obj)
            if(obj.event==='student_msg'){
                $.ajax({
                    type: "POST",
                    url: "/admin/classTimesId",
                    data: {id: data.id},
                    success: function (msg) {
                       if (msg.code==200){
                           window.location.href='/studentmsg';
                       }else {

                       }
                    }
                });
            }
        });
    })
    ;
</script>




</body>
</html>
</div>
</body>
</html>
